<template>
  <div>
    <h2>当前求和为{{ sum }}</h2>
    <h2>当前求和扩大十倍为{{ bigSum }}</h2>
    <el-select v-model="selectNumber" placeholder="请选择" class="my-select">
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
      </el-option>
    </el-select>
    <el-button @click="increment(selectNumber)" type="primary">+</el-button>
    <el-button @click="decrement(selectNumber)" type="success">-</el-button>
    <el-button @click="incrementIfOdd(selectNumber)" type="info">
      求和为奇数时+
    </el-button>
    <el-button @click="incrementAsync(selectNumber)" type="warning">
      异步+
    </el-button>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
// import _ from "lodash";
export default {
  name: "Count",
  data() {
    return {
      selectNumber: 1,
      options: [
        {
          value: 1,
          label: "1",
        },
        {
          value: 2,
          label: "2",
        },
        {
          value: 3,
          label: "3",
        },
        {
          value: 4,
          label: "4",
        },
        {
          value: 5,
          label: "5",
        },
      ],
    };
  },
  methods: {
    ...mapActions("countOptions", {
      increment: "increment",
      incrementIfOdd: "incrementIfOdd",
      incrementAsync: "incrementAsync",
    }),
    ...mapMutations("countOptions", { decrement: "DECREMENT" }),
  },
  computed: {
    ...mapState("countOptions", ["sum"]),
    ...mapGetters("countOptions", ["bigSum"]),
  },
};
</script>

<style lang='less' scoped>
.my-select {
  width: 66px;
  margin-right: 10px;
}
</style>